#include<bits/stdc++.h>

using namespace std;
int a[100];
int book[100];//标记数组  book[i]=1表示 i用过
int n = 4;

void dfs(int k) {
    if (k == n) {
        for (int i = 0; i < n; i++) {
            cout << a[i];
        }
        cout << endl;
        return;
    }
    for (int i = 1; i <= n; i++) {
        if (book[i] == 1)continue;
        book[i] = 1;
        a[k] = i;
        dfs(k + 1);
        book[i] = 0;
    }
}


int main() {
    dfs(0);
    return 0;
}